#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdlib.h>
using namespace std;





class Queue
{
public:
	Queue(int size = 10) :
		cap_(size),
		front_(0),
		rear_(0)，
        size_(0)

	{
		pQueue = new int[cap_];
	}
	~Queue()
	{
		delete[]pQueue;
		pQueue = nullptr;
	}
private:
	int* pQueue;
	int cap_;
	int front_;
	int rear_;
	int size_;
public:
	void expand(int size)
	{
		int* p =new int[size];
		int i = 0;
		int j=front_;
		for (; j != rear_; i++, j = (j + 1) % cap_)
		{
			p[i] = pQueue[j];
		}
		front_ = 0;
		cap_ = size;
		rear_ = i;
		delete[]pQueue;
		pQueue = p;
	}

public:
	void push(int val)
	{
		if ((rear_ + 1) % cap_ == front_)
		{
			expand(2*cap_);
		}
		pQueue[rear_] = val;
		rear_ = (rear_ + 1) % cap_;
		size_++;
	}
	void pop()
	{

		front_ = (front_ + 1) % cap_;
		size_--;
	}
	bool empty()
	{
		if (rear_ == front_)
			return true;
	}
public:
	//ͷԪ
	int  front()
	{
		if (rear_ == front_)
			throw "stack is empty";
		return pQueue[front_];
	}
public:
	//βԪ
	int rear()
	{
		if (rear_ == front_)
			throw "stack is empty";
		return pQueue[(rear_-1+cap_)%cap_];
	}
public:
	//ÿԪ
	void size()
	{
		for (int i=front_;i!=rear_;i=(1+i)%cap_)
		{
			cout<< pQueue[i]<<"\n";
		}

	}
};
int main()
{
	Queue qs;
	int Arr[10] = { 12,23,34,45,56,67,78,89,91,101 };
	for (int val : Arr)
	{
		qs.push(val);
	}
	qs.pop();
	qs.size();
	bool flag = qs.empty();
		if (flag == true)
		{
			cout << qs.front() << " ";
			cout << qs.rear() << " ";

		}
	
	return 0;
}